// var i;
// var $eventManager = require("./EventManager");
// var $resKeeper = require("./ResKeeper");
// var $evenType = require("./EvenType");
// var $playerDataManager = require("./PlayerDataManager");
// var $gameDataManager = require("./GameDataManager");
// var p = cc._decorator;
// var h = p.ccclass;
// var f = (p.property, p.inspector);
// var g = (function (e) {
//     function t() {
//         return (null !== e && e.apply(this, arguments)) || this;
//     }
//     __extends(t, e);
//     t.prototype.onEnable = function () {
//         $eventManager.EventMgr.addEventListener($evenType.EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.onUpdateUi, this);
//         $eventManager.EventMgr.addEventListener($evenType.EVENT_TYPE.Game_PASS, this.onUpdateUi, this);
//         this.onUpdateUi();
//     };
//     t.prototype.onDisable = function () {
//         $eventManager.EventMgr.rmEventListener($evenType.EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.onUpdateUi, this);
//         $eventManager.EventMgr.rmEventListener($evenType.EVENT_TYPE.Game_PASS, this.onUpdateUi, this);
//     };
//     t.prototype.onUpdateUi = function () {
//         if ($gameDataManager.GameDataMgr.getNowMaxLevel() >= 4) {
//             var e = $playerDataManager.PlayerDataMgr.getWuJinCount();
//             this.node.children[0].active = e > 0;
//         } else {
//             this.node.children[0].active = !1;
//         }
//     };
//     return __decorate([h], t);
// })($resKeeper.default);
// exports.default = g;


// import { EventMgrInstance } from "./EventManager";
// import ResKeeper from "./ResKeeper";
// import { EVENT_TYPE } from "./EvenType";
// import { PlayerDataMgr } from "./PlayerDataManager";
// import { GameDataMgr } from "./GameDataManager";

// const { ccclass, property, inspector } = cc._decorator;

// /**
//  * 建议类名: ChallengeCountUI
//  */
// @ccclass
// class ChallengeCountUI extends ResKeeper {

//     /**
//      * 当组件启用时调用，添加事件监听器
//      * 建议方法名: handleEnable
//      */
//     onEnable(): void {
//         EventMgrInstance.addEventListener(EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.onUpdateUi, this);
//         EventMgrInstance.addEventListener(EVENT_TYPE.Game_PASS, this.onUpdateUi, this);
//         this.onUpdateUi();
//     }

//     /**
//      * 当组件禁用时调用，移除事件监听器
//      * 建议方法名: handleDisable
//      */
//     onDisable(): void {
//         EventMgrInstance.rmEventListener(EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.onUpdateUi, this);
//         EventMgrInstance.rmEventListener(EVENT_TYPE.Game_PASS, this.onUpdateUi, this);
//     }

//     /**
//      * 更新UI，根据当前最大关卡和无尽模式次数设置节点的激活状态
//      * 建议方法名: updateUI
//      */
//     onUpdateUi(): void {
//         if (GameDataMgr.getNowMaxLevel() >= 4) {
//             const wuJinCount: number = PlayerDataMgr.getWuJinCount();
//             this.node.children[0].active = wuJinCount > 0;
//         } else {
//             this.node.children[0].active = false;
//         }
//     }
// }

// export default ChallengeCountUI;

import { EventMgrInstance } from "./EventManager";
import ResKeeper from "./ResKeeper";
import { EVENT_TYPE } from "./EvenType";
import { PlayerDataMgr } from "./PlayerDataManager";
import { GameDataMgr } from "./GameDataManager";

const { ccclass, property, inspector } = cc._decorator;

/**
 * 建议类名: ChallengeCountUI
 */
@ccclass
class ChallengeCountUI extends ResKeeper {

    /**
     * 当组件启用时调用，添加事件监听器
     * 建议方法名: handleEnable
     */
    onEnable(): void {
        EventMgrInstance.addListener(EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.updateUI, this);
        EventMgrInstance.addListener(EVENT_TYPE.Game_PASS, this.updateUI, this);
        this.updateUI();
    }

    /**
     * 当组件禁用时调用，移除事件监听器
     * 建议方法名: handleDisable
     */
    onDisable(): void {
        EventMgrInstance.removeListener(EVENT_TYPE.GAME_TIAOZHAN_COUNT, this.updateUI, this);
        EventMgrInstance.removeListener(EVENT_TYPE.Game_PASS, this.updateUI, this);
    }

    /**
     * 更新UI，根据当前最大关卡和无尽模式次数设置节点的激活状态
     * 建议方法名: updateUI
     */
    updateUI(): void {
        const nowMaxLevel = GameDataMgr.getCurrentMaxLevel();
        const wuJinModeCount = PlayerDataMgr.getWuJinCount();
        this.node.children[0].active = nowMaxLevel >= 4 && wuJinModeCount > 0;
    }
}

export default ChallengeCountUI;